package com.ww.springboot.boot.algorithm.dp.study;

/**
 * 描述：爬楼梯
 * 1 2 3 5
 * F(n) = F(n-1)+F(n-2)
 *
 * @author wanwei
 * @since 2021-11-08 15:43
 */
public class ClimbStairs2 {

    public static void main(String[] args) {
        System.out.println(climbStairs(10));
    }


    public static int climbStairs(int n) {
        int[] tmp = {2, 1};
        for (int i = 3; i <= n; i++)
            tmp[i % 2] = tmp[1] + tmp[0];
        return tmp[n % 2];
    }
}
